package binary_tree.leetcode;

/**
 * 求二叉树的深度
 * @Author Stark
 * @Date 2022/2/22 9:52
 */
public class Num104_DepthOfTree {
    public int maxDepth(TreeNode root) {
        if(root == null){
            return 0;
        }
        //判断左树和右数的深度较大者进行返回
        int left = 1 + maxDepth(root.left);
        int right = 1 + maxDepth(root.right);
        return Math.max(left,right);
    }
}
